package com.special.threademo.thread;

/**
 * @author liuYC
 * @ClassName ThreadDemo
 * @Description TODO
 * @date 2021/4/26 7:38
 */
public class ThreadDemo extends Thread {
    @Override
    public void run() {
        System.out.println("thread execute  ^^^^^^");
    }

    //    static class 和class区别：为什么new class 会报错：
//    静态内部类和非静态内部类之间区别:
    static class RunDemo implements Runnable {

        @Override
        public void run() {
            System.out.println("runnable execute ^^^^^^");
        }
    }

    public static void main(String[] args) {
        ThreadDemo threadDemo = new ThreadDemo();
//       therad类设置线程名字的方法：
        threadDemo.setName("thread-name");
        threadDemo.start();
        System.out.println(threadDemo.getName());
        RunDemo target = new RunDemo();
        Thread runnable = new Thread(target, "runnable-name");
        runnable.start();
        System.out.println(runnable.getName());
    }
}
